package com.kingdee.eas.custom.hr.attendance.app;

import org.apache.log4j.Logger;
import javax.ejb.*;
import java.rmi.RemoteException;
import java.util.Iterator;
import java.util.Set;

import com.kingdee.bos.*;
import com.kingdee.bos.util.BOSObjectType;
import com.kingdee.bos.metadata.IMetaDataPK;
import com.kingdee.bos.metadata.rule.RuleExecutor;
import com.kingdee.bos.metadata.MetaDataPK; //import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.framework.ejb.AbstractEntityControllerBean;
import com.kingdee.bos.framework.ejb.AbstractBizControllerBean; //import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.IObjectCollection;
import com.kingdee.bos.service.ServiceContext;
import com.kingdee.bos.service.IServiceContext;

import java.lang.String;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.eas.custom.hr.attendance.NursingLeaveCollection;
import com.kingdee.eas.custom.hr.attendance.SickVacationMgrCollection;
import com.kingdee.eas.custom.hr.attendance.SickVacationMgrInfo;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.custom.hr.attendance.NursingLeaveInfo;
import com.kingdee.eas.framework.ObjectBaseCollection;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.eas.framework.app.ObjectBaseControllerBean;
import com.kingdee.eas.framework.CoreBaseCollection;

public class NursingLeaveControllerBean extends
		AbstractNursingLeaveControllerBean {
	private static Logger logger = Logger
			.getLogger("com.kingdee.eas.custom.hr.attendance.app.NursingLeaveControllerBean");

	@Override
	protected void _saveNursingLeave(Context ctx, IObjectValue nursingLeave)
			throws BOSException, EASBizException {
		Set addSet = (Set) nursingLeave.get("addSet");
		Set updateSet = (Set) nursingLeave.get("updateSet");
		Set deleteSet = (Set) nursingLeave.get("deleteSet");

		Iterator it = addSet.iterator();
		NursingLeaveInfo info = null;

		NursingLeaveCollection colls = new NursingLeaveCollection();
		while (it.hasNext()) {
			info = (NursingLeaveInfo) it.next();
			colls.add(info);
		}
		this._saveBatchData(ctx, colls);

		IObjectPK[] pks = new ObjectUuidPK[deleteSet.size()];
		int i = 0;
		it = deleteSet.iterator();
		while (it.hasNext()) {
			info = (NursingLeaveInfo) it.next();
			pks[i++] = new ObjectUuidPK(info.getId());
		}
		this.deleteBatchData(ctx, pks);

		CoreBaseCollection collection = new CoreBaseCollection();
		it = updateSet.iterator();
		while (it.hasNext()) {
			info = (NursingLeaveInfo) it.next();
			collection.add(info);
		}

		this.updateBatchData(ctx, collection);
	}

}